<template>
	<view class="content">
		<button class="size" @tap="getDevice(site)" v-for="site in deviceList" :key="site">{{site}}属性</button>
		<view>{{value}}</view>
		<button class="size" @tap="beep">beep发出蜂鸣声</button>
		<button class="size" @tap="dial">dial拨打电话</button>
		<button class="size" @tap="getInfo">getInfo获取设备信息</button>
		<button class="size" @tap="getVolume">getVolume获取设备的系统音量{{Volume}}</button>
		<button class="size" @tap="setVolume">setVolume设置设备的系统音量</button>
		<button class="size" @tap="vibrate">vibrate设备振动</button>
		<button class="size" @tap="screenEvent(site)" v-for="site in screenList" :key="site">{{site}}模块管理设备屏幕信息</button>
		<view>
			{{screenzvalue}}
		</view>
		<button class="size" @tap="setBrightness">setBrightness调节设备屏幕亮度</button>
		<button class="size" @tap="getBrightness">getBrightnes获取屏幕亮度</button>
		<button class="size" @tap="lockOrientation">lockOrientation锁定屏幕方向</button>
		<button class="size" @tap="unlockOrientation">unlockOrientation解除锁定屏幕方向</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				deviceList: ["imei", "imsi", "model", "vendor", "uuid"],
				value: "",
				Volume:0,
				screenList:["dpiX","dpiY","height","width","resolutionHeight","resolutionWidth","scale"],
				screenzvalue:""
			}
		},
		onLoad() {

		},
		methods: {
			getDevice(key) {
				this.value = plus.device[key];
			},
			beep() {
				plus.device.beep(4);
			},
			dial() {
				const number = "XXX"
				plus.device.dial(number, false);
			},
			getInfo() {
				plus.device.getInfo({
					success: function(e) {
						Object.keys(e).forEach(key=>{
							console.log("success",key,e[key])
						})
					},
					fail: function(e) {
						Object.keys(e).forEach(key=>{
							console.log("failed",key,e[key])
						})
					}
				});
			},
			getVolume(){
				this.Volume = plus.device.getVolume();
			},
			setVolume(){
				plus.device.setVolume(1);
			},
			vibrate(){
				const milliseconds = 2000;
				plus.device.vibrate(milliseconds);
			},
			screenEvent(key){
				this.screenzvalue = plus.screen[key]
			},
			setBrightness(){
				plus.screen.setBrightness( 0.1 );
			},
			getBrightness(){
				plus.screen.getBrightness();
			},
			lockOrientation(){
				plus.screen.lockOrientation("portrait-primary");

			},
			unlockOrientation(){
				plus.screen.unlockOrientation();
			}

		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}

	.size {
		margin: 30rpx 0;
	}
</style>
